<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="项目名称" prop="extractItem">
        <el-input
          v-model="queryParams.extractItem"
          placeholder="请输入项目名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="抽取人单位" prop="createBy">
        <el-select
          v-model="queryParams.createBy"
          placeholder="请选择抽取人单位"
          clearable
          size="small"
          style="width: 100%"
          @change="UnitTypeChangepenson"
        >
          <el-option
            v-for="type in unitTypeponsonOptions"
            :key="type.userId"
            :label="type.nickName"
            :value="type.userId"
          />
        </el-select>

      </el-form-item>

      <el-form-item label="抽取库" prop="randomUnittypeId">
        <el-select
          v-model="queryParams.randomUnittypeId"
          placeholder="请选择单位库"
          clearable
          size="small"
          style="width: 100%"
          @change="UnitTypeChange"
        >
          <el-option
            v-for="type in unitTypeOptions"
            :key="type.unittypeId"
            :label="type.unittypeName"
            :value="type.unittypeId"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="状态" prop="extractApproveStatus">
        <el-select
          v-model="queryParams.extractApproveStatus"
          placeholder="请选择状态"
          clearable
          size="small"
          style="width: 100%"
        >
          <el-option
            v-for="(item, index) in statuses"
            :key="index"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['unit:extract:export']"
          >导出</el-button
        >
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="extractList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="项目名称" align="left" prop="extractItem" />
      <el-table-column label="申请单位" align="left" prop="createBy" />
      <!-- <template>
          {{ createBy }}
        </template>
      </el-table-column> -->
      <el-table-column label="申请账号" align="left" prop="userName" />
      <el-table-column
        label="抽取库"
        show-overflow-tooltip
        align="left"
        prop="randomUnittypeId"
        :formatter="unitTypeFormat"
      />
      <el-table-column
        label="抽取时间"
        align="left"
        prop="tenderStartTime"
        :sortable="true"
      />
      <el-table-column
        label="经办人"
        align="left"
        prop="extractCharge"
        :sortable="true"
      />
      <!-- <el-table-column label="建设地址" align="left" prop="extractAddress" /> -->
      <!-- <el-table-column label="确认时间" align="left" prop="makeSureTime" />
      <el-table-column
        label="评价时间"
        align="left"
        prop="evaluateTime"
        width="250"
      /> -->
      <el-table-column
        label="工程费用（万元）"
        align="left"
        prop="extractPrice"
      />
      <el-table-column
        label="中介机构服务费（万元）"
        align="left"
        prop="maxPrice"
      />
      <el-table-column
        label="审批状态"
        align="center"
        prop="extractApproveStatus"
        :formatter="approveStatusFormat"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="270"
      >
        <template slot-scope="scope">
          <el-button
            v-if="
              scope.row.extractApproveStatus === '7' ||
              scope.row.extractApproveStatus === '8'
            "
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateDialog(scope.row)"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="ResultOpentitle(scope.row)"
            v-hasPermi="['unit:extract:edit']"
            v-if="scope.row.extractApproveStatus == 7"
            >结果查看</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-remove-outline"
            v-hasPermi="['unit:extract:edit']"
            v-if="scope.row.extractApproveStatus != 7"
            >未抽取完成</el-button
          > -->
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-back"
            v-hasPermi="['unit:extract:edit']"
            v-if="
              scope.row.extractApproveStatus == 7 || scope.row.extractApproveStatus == 6
            "
            @click="retreat(scope.row)"
            >退回抽签</el-button
          > -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            v-hasPermi="['unit:extract:edit']"
            @click="handleUpdate(scope.row)"
            >项目详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="
        getList(queryParams.extractApproveStatus == '' ? true : false)
      "
    />

    <!-- 单位信息对话框 -->
    <!-- <el-dialog :title="title" :visible.sync="unitopen" width="400px" append-to-body>
      <div class="unitSort-box">
        <ul style="list-style: none">
          <li>单位序号:{{ formUnit.unitSort }}</li>
          <li>单位名称:{{ formUnit.unitName }}</li>
          <li>资质等级:{{ formUnit.unitNaturalGrade }}</li>
          <li>资质范围:{{ formUnit.unitNaturalScope }}</li>
          <li>注册地址:{{ formUnit.unitAddress }}</li>
          <li>备注:{{ formUnit.unitRemarks }}</li>
        </ul>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormUnit">确 定</el-button>
      </div>
    </el-dialog> -->
    <DetailDialog :visible.sync="unitopen" :formUnit="formUnit" />
    <!-- 添加或修改项目申请对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1200px"
      append-to-body
      v-if="open"
      :before-close="cancel"
    >
      <div class="form-content">
        <el-tabs v-model="activeName" type="card" @tab-click="() => {}">
          <el-tab-pane label="项目详情" name="1">
            <el-form ref="form" :model="form" label-width="168px">
              <el-row>
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="申请单位：" prop="createBy">{{
                      form.createBy
                    }}</el-form-item>
                  </el-col>
                  <el-col
                    :span="12"
                    style="padding-top: -20px; padding-bottom: -50px"
                  >
                    <el-form-item label="项目名称：" prop="extractItem">
                      {{ form.extractItem }}
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="建设周期：" prop="extractPeriod">
                      {{ form.extractPeriod }}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="建设地址：" prop="extractAddress">
                      {{ form.extractAddress }}
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="工程费用(万元)：" prop="extractPrice">
                      {{ form.extractPrice }}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      label="中介机构服务费（万元）："
                      prop="maxPrice"
                    >
                      {{ form.maxPrice }}
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-row>
              <br />
              <el-row style="margin-top: -15px">
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="经办人：" prop="extractCharge">
                      {{ form.extractCharge }}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="联系电话：" prop="extractPhone">
                      {{ form.extractPhone }}
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="业务类型：" prop="extractBusinessType">
                      {{ form.extractBusinessType }}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="是否驻场服务：">
                      {{ form.extractResident == 0 ? "是" : "否" }}
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="工程概况：" prop="projectOverview">
                      {{ form.projectOverview }}
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="15">
                  <el-col :span="12">
                    <el-form-item label="抽取要求：" prop="extractBanReason">
                      {{ form.extractBanReason }}
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <!-- <el-col :span="12" v-if="form.extractResident === '0'">
                    {{ form.extractResidentNumber }}
                  </el-col>
                  <el-col :span="12" v-if="form.extractResident === '0'">
                    <el-form-item label="完成时限：" prop="extractLimitedTime">
                      <el-date-picker
                        v-model="form.extractLimitedTime"
                        value-format="yyyy-MM-dd"
                        type="date"
                        style="width: 100%"
                      >
                      </el-date-picker>
                    </el-form-item>
                  </el-col> -->
                </el-row>
                <el-row>
                  <el-form-item
                    v-if="form.extractResident === '0'"
                    label="驻场要求："
                  >
                    {{ form.extractStationRequire }}
                  </el-form-item>
                </el-row>
              </el-row>
              <el-row :gutter="15">
                <el-col :span="12">
                  <el-form-item label="抽取库：" prop="unitTypeName">
                    {{ form.unitTypeName }}
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="抽取单位数：" prop="extractNumber">
                    {{ form.extractNumber }}
                  </el-form-item>
                </el-col>
              </el-row>
              <br />
              <!-- 库下对应单位表格 -->
              <div class="streach-icon">
                <div class="blue-line" v-show="!stretch"></div>
                <i
                  :class="!stretch ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
                  @click="stretch ? (stretch = false) : (stretch = true)"
                ></i>
              </div>
              <div
                :class="!stretch ? 'stretchable-hidden' : 'stretchable-visible'"
              >
                <el-table
                  v-loading="loading"
                  id="unitTable"
                  :data="unitList"
                  max-height="400"
                  :row-style="rowStyle"
                >
                  <el-table-column
                    label="序号"
                    align="center"
                    prop="unitSort"
                    width="100"
                  />
                  <el-table-column
                    label="单位名称"
                    align="left"
                    prop="unitName"
                    width="300"
                  />
                  <!-- <el-table-column
            label="资质等级"
            align="left"
            prop="unitNaturalGrade"
            width="170"
          /> -->
                  <!-- <el-table-column label="注册地址" align="left" prop="unitAddress" width="300" /> -->
                  <!-- <el-table-column
            label="手动排除"
            align="center"
            prop="extractPrice"
            :formatter="ManualApproveStatusFormat"
            width="120"
          /> -->
                  <el-table-column
                    label="是否选中"
                    align="center"
                    prop="isTick"
                  >
                    <template slot-scope="scope">
                      {{ scope.row.isTick == 0 ? "未选中" : "选中" }}
                    </template>
                  </el-table-column>
                  <!-- <el-table-column
                    label="是否中签"
                    align="center"
                    prop="isRandom"
                  >
                    <template slot-scope="scope">
                      {{ scope.row.isRandom == 1 ? "中签" : "未中签" }}
                    </template>
                  </el-table-column> -->
                  <el-table-column
                    label="是否禁用"
                    align="center"
                    prop="forbidden"
                  >
                    <template slot-scope="scope">
                      {{ scope.row.forbidden == 0 ? "未禁用" : "禁用" }}
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="未选择理由"
                    align="center"
                    prop="notWonReason"
                  >
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    align="center"
                    class-name="small-padding fixed-width"
                    width="100"
                  >
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        @click="unitShow(scope.row)"
                        v-hasPermi="['unit:extract:edit']"
                        >单位详情</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <!-- 抽取信息部分 -->
              <!-- <div class="section-margin">
                <p class="table-title">抽取信息</p>
                <EmbedTable :tableData="randomList" />
              </div> -->
              <div class="section-margin" v-show="form.extractNumber > 1">
                <p class="table-title">比价信息</p>
                <simpleTable :simpleTableData="simpleTableData" />
              </div>
              <div class="section-margin">
                <el-form-item label="确认时间：">
                  {{ randomList[0] && randomList[0].updateTime }}
                </el-form-item>
                <el-form-item label="备注：">
                  {{
                    randomList[0] && randomList[0].randoms.length > 0
                      ? randomList[0].randoms[0].randomBanRansom
                      : ""
                  }}
                </el-form-item>
              </div>
              <div class="section-margin">
                <p class="table-title">抽取信息</p>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="抽取时间：">
                      {{ randomList[0] ? randomList[0].createTime : "" }}
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="中标单位：">
                      {{
                        randomList[0] && randomList[0].randomBan == 3
                          ? randomList[0].randomUnitName
                          : ""
                      }}
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <!-- 评价信息部分 -->
              <div class="section-margin">
                <p class="table-title">评价信息</p>
                <Evaluation :evaluation="evaluation" />
              </div>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="项目日志" name="2">
            <el-table :data="logs">
              <el-table-column label="序号" align="left" prop="index" />
              <el-table-column
                label="日志详情"
                align="left"
                prop="operateName"
              />
              <el-table-column label="操作人" align="left" prop="userName" />
              <el-table-column
                label="操作时间"
                align="left"
                prop="operateTime"
              />
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button @click="cancel" type="primary">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 查看项目抽签结果对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="resultOpen"
      width="800px"
      append-to-body
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="120px"
        style="width: 700px; padding-left: 50px"
      >
        <table
          class="printTable"
          border="1"
          id="printMe"
          cellspacing="0"
          width="100%"
          height="800px"
        >
          <caption align="top" style="margin-bottom: 30px; font-size: 24px">
            重庆高新开发建设投资集团有限公司中介机构抽取结果表
          </caption>
          <tr>
            <td
              colspan="3"
              style="text-align: left"
              height="40px"
              class="font-FangSong topfont noBorder title-font"
            >
              申请单位：{{ form.createBy }}
            </td>
            <td
              colspan="2"
              style="text-align: right"
              class="topfont noBorder font-FangSong"
            >
              日期：{{ form.createTime | dateTime }}
            </td>
          </tr>
          <tr>
            <th rowspan="3" width="80px" class="bigfont">
              项 目 基
              <br />
              本 情 况
            </th>
            <td width="120px" height="60px" class="small font-SimHei">
              项 目 名 称
            </td>
            <th colspan="3" class="input commonBorder font-FangSong">
              {{ form.extractItem }}
            </th>
          </tr>
          <tr>
            <td class="small font-SimHei">建 设 地 址</td>
            <th colspan="3" class="input commonBorder font-FangSong">
              {{ form.extractAddress }}
            </th>
          </tr>
          <tr>
            <td class="small font-SimHei">
              工 程 费 用
              <br />
              (万 元)
            </td>
            <th width="150px" class="input font-FangSong">
              {{ form.extractPrice }}
            </th>
            <td width="80px" class="small font-SimHei">建 设 周 期</td>
            <th class="input commonBorder font-FangSong">
              {{ form.extractPeriod }}
            </th>
          </tr>
          <tr>
            <th :rowspan="rowspanList" class="bigfont">中 标<br />信 息</th>
            <td class="small font-SimHei">抽 取 库</td>
            <th class="input font-FangSong">{{ form.unitTypeName }}</th>
            <td class="small font-SimHei">
              中介机构服务费
              <br />
              (万 元）
            </td>
            <th class="input commonBorder font-FangSong">
              {{ form.maxPrice }}
            </th>
          </tr>
          <tr>
            <td class="small font-SimHei">业 务 类 型</td>
            <th class="input font-FangSong">{{ form.extractBusinessType }}</th>
            <td class="small font-SimHei">抽 取 时 间</td>
            <th class="input commonBorder font-FangSong">
              {{ form.updateTime | dateTime }}
            </th>
          </tr>
          <tr>
            <td
              colspan="4"
              height="60px"
              class="small commonBorder font-SimHei"
            >
              中 标 单 位 列 表
            </td>
          </tr>
          <tr>
            <td height="60px" class="small font-SimHei">序 号</td>
            <td class="small font-SimHei">单 位 名 称</td>
            <td width="120px" class="small font-SimHei">联 系 人</td>
            <td width="120px" class="small commonBorder font-SimHei">
              联 系 电 话
            </td>
          </tr>
          <tr v-if="items == ''">
            <th height="60px"></th>
            <th></th>
            <th></th>
            <th class="commonBorder"></th>
          </tr>
          <tr v-for="(item, index) in items" :key="item.id">
            <th height="60px" class="input font-FangSong">{{ index + 1 }}</th>
            <th class="input font-FangSong">{{ item.randomUnitName }}</th>
            <th class="input font-FangSong">{{ item.randomLinkman }}</th>
            <th class="input commonBorder font-FangSong">
              {{ item.randomPhone }}
            </th>
            
          </tr>
       
          <tr>
            <th rowspan="4" class="bigfont a1">
              参 与 抽
              <br />
              取 人 员
            </th>
            <td class="small font-SimHei">抽 取 地 点</td>
            <th class="input commonBorder font-FangSong" colspan="3">
              {{ form.extractPlace }}
            </th>
          </tr>
          <tr class="a1">
            <td class="small font-SimHei">现 场 抽 取 人</td>
            <th colspan="3" class="input commonBorder font-FangSong">
              {{ form.extractUser }}
            </th>
          </tr>
        </table>

        <el-button
          v-print="'#printMe'"
          type="primary"
          style="margin-top: 10px; margin-left: 90%"
          >打 印</el-button
        >
      </el-form>
    </el-dialog>
    <updateDialog
      :updateDialogVisible="updateDialogVisible"
      @handleUpdateClose="handleUpdateClose"
      :unitTypeOptions="unitTypeOptions"
      :currentRow="currentRow"
      :tableCompany="tableCompany"
      :companyInfo="companyInfo"
      :deductScore="deductScore"
    />
  </div>
</template>

<script>
import {
  listExtract,
  getExtract,
  delExtract,
  addExtract,
  updateExtract,
  exportExtract,
  getExtractArticle,
  getTableCompany,
} from "@/api/unit/extract";
import FileUpload from "@/components/FileUpload";
import { listRandom } from "@/api/unit/random";
import { listUser } from "@/api/system/user";
import {
  listUnit,
  randomlist,
  getUnit,
  delUnit,
  addUnit,
  updateUnit,
  exportUnit,
  getLog,
  getExtractUnit,
} from "@/api/unit/unit";
import { Department } from "@/api/unit/extract";
import { listUnittype, getUnittype } from "@/api/unit/unittype";
import EmbedTable from "@/components/EmbedTable";
import Evaluation from "./components/Evaluation";
import updateDialog from "@/views/unit/extract/view/components/updateDialog";
import DetailDialog from "@/common/detailDialog";
import simpleTable from "@/common/operation/simpleTable";

export default {
  name: "Extract",
  components: {
    FileUpload,
    updateDialog,
    Evaluation,
    EmbedTable,
    DetailDialog,
    simpleTable,
  },
  data() {
    return {
      //  修改弹窗
      updateDialogVisible: false,
      //打开预览
      innerVisible: false,
      detailVisible: false,
      // 遮罩层
      loading: true,
      //动态控制rowspan
      rowspanList: 5,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      //是否显示弹窗
      unitopen: false,
      //项目抽签结果层
      resultOpen: false,
      // 总条数
      total: 0,
      // 项目申请表格数据
      //循环表格数组
      items: [],
      extractList: [],
      // 单位信息表格数据
      unitList: [],
      // 单位类型字典
      unitTypeOptions: [],
      //抽取人单位字典
      unitTypeponsonOptions: [],
      //弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        createBy:null,
        randomUnittypeId:null,
        extractItem: null,
        extractUser: null,
        extractAddress: null,
        extractPrice: null,
        extractApproveStatus: "",
        maxPrice: null,
      },
      UnitqueryParams: {
        pageNum: 1,
        pageSize: 10,
        unitName: null,
        unitNaturalGrade: null,
        unitNaturalScope: null,
        unitType: null,
        extractId: "",
      },
      // 表单参数
      form: {},
      //单位详情
      formUnit: {},
      //单位详情表单重置
      resetUnit() {
        this.formUnit = {
          unitId: null,
          unitSort: null,
          unitType: null,
          unitName: null,
          unitNaturalGrade: null,
          unitNaturalScope: null,
          unitAddress: null,
          unitRemarks: null,
        };
      },
      // 查询参数
      RandomqueryParams: {
        pageNum: 1,
        pageSize: 10,
        extractId: null,
        randomUnitId: null,
        randomBan: "0",
        annex: null,
      },
      // 表单校验
      rules: {
        extractUser: [
          { required: true, message: "抽取人不能为空", trigger: "blur" },
        ],
        extractUnit: [
          { required: true, message: "抽取单位不能为空", trigger: "blur" },
        ],
        randomUnittypeId: [
          { required: true, message: "抽取库不能为空", trigger: "change" },
        ],
      },
      currentRow: {},
      companyInfo: [],
      tableCompany: [],
      deductScore: [],
      detailRow: {},
      randomList: [],
      evaluation: [],
      createBy: "",
      statuses: [
        // {
        //   label: "申请中",
        //   value: 1,
        // },
        {
          label: "审批通过",
          value: 2,
        },
        {
          label: "审批拒绝",
          value: 3,
        },
        {
          label: "已抽取",
          value: 4,
        },
        {
          label: "已发布",
          value: 5,
        },
        {
          label: "待确认",
          value: 6,
        },
        {
          label: "项目执行中",
          value: 7,
        },
        {
          label: "项目完成",
          value: 8,
        },
      ],
      activeName: "1",
      logs: [],
      simpleTableData: {
        title: ["单位名称", "报价情况（万元）"],
        list: [],
      },
      stretch: false,
    };
  },
  created() {
    listUnittype(this.unitTypeParams).then((response) => {
      this.unitTypeOptions = response.rows;
    });
    listUser().then((response) => {
      this.unitTypeponsonOptions = response.rows;
    });
    // Department().then((res) => {
    //   this.createBy = res.data.createBy;
    //   this.getList(true);
    // });
    this.getList(true);
  },
  methods: {
    // 关闭修改弹窗
    handleUpdateClose() {
      this.tableCompany = [];
      this.companyInfo = [];
      this.updateDialogVisible = false;
    },
    async handleUpdateDialog(row) {
      this.currentRow = row;
      // 获取单位信息
      const result = await getTableCompany({
        extractId: row.extractId,
        extractApproveStatus: row.extractApproveStatus,
      });
      // 表格单位信息
      this.tableCompany = result.data.randoms;
      // 单位下拉数据
      result.data.randoms.map((item) => {
        this.companyInfo.push({
          randomId: item.randomId.toString(),
          randomUnitName: item.randomUnitName,
          randomBan: item.randomBan,
        });
      });
      // 违规扣分
      if (result.data.scoreindex !== null) {
        this.deductScore = result.data.scoreindex;
      }
      this.updateDialogVisible = true;
    },
    //抽取人单位
    UnitTypeChangepenson(value) {
      if (!value) {
        this.queryParams.createBy = null;
      }
      listUser().then((response) => {
        for (var o = 0; o < response.rows.length; o++) {
          if (value == response.rows[o].userId) {
            this.queryParams.createBy = response.rows[o].nickName;
            break;
          }
        }
      });
    },
    /** 查询项目申请列表 */
    getList(init) {
      const query = { ...this.queryParams };
      if (
        (init && typeof init === "boolean") ||
        query.extractApproveStatus == ""
      ) {
        query.extractApproveStatus = "2,6,7,8";
      }
      this.loading = true;
      // query.randomUnittypeId = this.form.randomUnittypeId;
      listExtract(query)
        .then((response) => {
          this.extractList = response.rows;
          this.total = response.total;
        })
        .finally(() => (this.loading = false));
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.activeName = "1";
      this.reset();
      this.simpleTableData.list = [];
    },
    // 表单重置
    reset() {
      this.form = {
        extractId: null,
        extractItem: null,
        extractUser: null,
        extractUnit: null,
        extractRemarks: null,
        extractBanReason: null,
        extractScore: null,
        extractApproveStatus: "1",
        extractApproveIdea: null,
        randomUnittypeId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        extractNumber: null,
      };
      this.resetForm("form");
    },
    // 单位库类型翻译
    unitTypeFormat(row, column) {
      return this.selecttypeLabel(this.unitTypeOptions, row.randomUnittypeId);
    },
    //单位选择select改变方法
    UnitTypeChange(value) {
      //让table显现出来

      //查询table数据
      this.UnitqueryParams.unitType = value;
      randomlist(this.UnitqueryParams).then((response) => {
        this.unitList = response.rows;
        this.loading = false;
      });
    },
    //转换单位库类型
    selecttypeLabel(datas, value) {
      var actions = [];
      Object.keys(datas).some((key) => {
        if (datas[key].unittypeId == "" + value) {
          actions.push(datas[key].unittypeName);
          return true;
        }
      });
      return actions.join("");
    },
    approveStatusFormat(row, column) {
      return this.getType(row, column);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 单位详情 */
    unitShow(row) {
      const unitId = row.unitId || this.ids;
      getUnit(unitId).then((response) => {
        this.formUnit = response.data;
        this.unitopen = true;
        this.title = "单位详情";
      });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.reset();
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.extractId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    //单位详情提交按钮
    submitFormUnit() {
      this.unitopen = false;
      this.resetUnit();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加项目申请";
    },
    /** 详情按钮操作 */
    handleUpdate(row) {
      this.reset();
      const extractId = row.extractId || this.ids;
      getExtract(extractId).then((response) => {
        this.form = response.data;
        this.UnitqueryParams.unitType = this.form.randomUnittypeId;
        this.UnitqueryParams.extractId = extractId;
        this.randomList = response.data.randomList;
        this.evaluation = response.data;
        const scoreindexList = [...this.evaluation.scoreindexList];
        this.evaluation.scoreindexList = []
        let indexList = [];
        let secondList = [];
        for(let i in scoreindexList) {
          if((i-(-1))%2 == 0) {
            indexList.push(scoreindexList[i]);
            if(indexList.length == 2) {
              this.evaluation.scoreindexList.push(indexList);
              indexList = [];
            }
          } else {
            secondList.push(scoreindexList[i]);
            if(secondList.length == 2) {
              this.evaluation.scoreindexList.push(secondList);
              secondList = [];
            }
          }
        }
        getExtractUnit({ extractId: row.extractId }).then((response) => {
          response.rows.forEach((item, index) => (item.unitSort = index + 1));
          this.unitList = response.rows;
          this.loading = false;
        });
        this.open = true;
        this.title = "项目详情";
        const compareInfo = this.randomList.map((item) => item.randoms);
        this.loadExtractArticle(compareInfo.flat([1]));
      });
      // getLog(extractId).then((res) => {
      //   res.data.forEach((item, index) => (item.index = index + 1));
      //   this.logs = res.data;
      // });
    },
    //结果查看按钮操作
    ResultOpentitle(row) {
      const extractId = row.extractId || this.ids;
      this.RandomqueryParams.extractId = extractId;
      this.RandomqueryParams.randomBan = "3"; //查询状态为中签的记录
      if (this.items.length >1) {
        this.rowspanList=6;
      } else {
        this.rowspanList=5;
      }
      listRandom(this.RandomqueryParams).then((response) => {
        this.items = response.rows;
      });
      getExtract(extractId).then((response) => {
        this.form = response.data;
        this.resultOpen = true;
        this.title = "";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.extractId != null) {
            updateExtract(this.form).then((response) => {
              this.msgSuccess("审批完成");
              this.open = false;
              this.getList();
            });
          } else {
            addExtract(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const extractIds = row.extractId || this.ids;
      this.$confirm(
        '是否确认删除项目申请编号为"' + extractIds + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delExtract(extractIds);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有项目申请数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportExtract(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
    //退回抽签
    // retreat(row) {
    //   this.$confirm("将退回抽签，是否确认？", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       const newRow = { ...row };
    //       newRow.extractApproveStatus = 2;
    //       retreatRandom(newRow).then((res) => {
    //         row.extractApproveStatus = 2;
    //       });
    //     })
    //     .catch((err) => {});
    // },
    AutomaticApproveStatusFormat(row, column) {
      if (row.unitStatues == 0) {
        return "否";
      } else if (row.unitStatues == 1) {
        return "否";
      } else if (row.unitStatues == 2) {
        return "是";
      } else if (row.unitStatues == 3) {
        return "是";
      } else if (row.randomBan == 4) {
        return "未中标";
      } else if (row.randomBan == 5) {
        return "废除报价";
      }
    },
    ManualApproveStatusFormat(row, column) {
      if (row.unitStatues == 0) {
        return "否";
      } else if (row.unitStatues == 1) {
        return "是";
      } else if (row.unitStatues == 2) {
        return "否";
      } else if (row.unitStatues == 3) {
        return "否";
      } else if (row.randomBan == 4) {
        return "未中标";
      } else if (row.randomBan == 5) {
        return "废除报价";
      }
    },
    async loadExtractArticle(row) {
      // const res = await getExtractArticle({ randomBan: 3, extractId: row.extractId });
      for (var i = 0; i < row.length; i++) {
        const obj = row[i];
        for (const j in obj) {
          if (obj[j] === null) {
            obj[j] = "";
          } else {
            obj[j] = obj[j];
          }
        }
      }
      row.forEach((item) => {
        this.simpleTableData.list.push([item.randomUnitName, item.bidamount]);
        // for (var i = 0; i < this.simpleTableData.list.length; i++) {
        //   if (i >= 1) {
        //     this.simpleTableData.list.splice(0, 1);
        //   }
        // }
      });
    },
    rowStyle({ row }) {
      let style = {};
      if (row.isTick == 0 || row.notWonReason)
        style.backgroundColor = "#ffe4e1";
      return style;
    },
  },
  filters: {
    dateTime(val) {
      if (val) {
        return val.substr(0, 10);
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.topbox {
  width: 100%;
  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.08);
}
.btobox {
  width: 100%;
  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.08);
}
::v-deep .el-table .cell {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

::v-deep .el-table .cell:hover {
  white-space: normal;
}

.form-img-out {
  width: 130px;
  height: 130px;
}
.form-img-line {
  width: 500px;
  height: 500px;
}
.form-dialog {
  text-align: center;
}
.topfont {
  font-size: 16px;
  font-weight: 400;
}
.small {
  text-align: center;
  font-weight: 100;
  font-size: 16px;
}
.bigfont {
  font-size: 18px;
  font-weight: 100;
  text-align: center;
  font-family: FangSong;
}
.input {
  font-size: 16px;
  font-weight: 400;
}
::v-deep .el-table .denger-row {
  background: #ffe4e1;
}
::v-deep .el-date-editor {
  margin-left: -4px;
}
.printTable {
  border: unset;
}
.noBorder {
  border: unset;
}
.commonBorder {
  border-right: 1px solid #9a9a9a;
}
.a1 {
  border-bottom: 1px solid #9a9a9a;
}
.title-font {
  font-family: FangSong;
}
.font-SimHei {
  font-family: FangSong;
}
.font-FangSong {
  font-family: FangSong;
}
.unitSort-box {
  text-align: left;
}
.unitSort-box li {
  margin-top: 5px;
}
.ceshi {
  width: 100%;
  height: 20px;
  text-align: left;
  line-height: 20px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-left: 9px;
  color: #ff0000;
  font-size: 12px;
}
::v-deep .stretchNone {
  .el-textarea__inner {
    resize: none;
  }
}
::v-deep .el-input.is-disabled .el-input__inner,
::v-deep .el-textarea.is-disabled .el-textarea__inner {
  color: #606266;
  background-color: transparent;
}
.table-title,
::v-deep .el-dialog__title {
  font-size: 18px;
  font-weight: bold;
  color: #303133;
}
.section-margin {
  margin-top: 32px;
}

.form-content {
  ::v-deep .el-form-item__label {
    padding: 0;
  }
  ::v-deep .el-form-item {
    margin-bottom: 12px;
  }
}
.stretchable-hidden {
  height: 0px;
  visibility: hidden;
}
.stretchable-visible {
  height: unset;
}
.streach-icon {
  position: relative;
  margin-bottom: 10px;
  i {
    position: absolute;
    right: 0;
    top: -4px;
    cursor: pointer;
    &::after {
      position: absolute;
      bottom: 10px;
      right: 0;
      display: block;
      content: "展开/收起抽取单位列表";
      color: rgb(64, 158, 255);
      width: 146px;
      height: 30px;
    }
  }
  .blue-line {
    bottom: 50%;
    right: 0;
    height: 1px;
    width: 98%;
    background-color: #c0c0c0;
  }
}
</style>
